$(function() {
    $( "#slider" ).slider({
	value:12,
	min: 0,
	max: 30,
	slide: function( event, ui ) {
	    $( "#amount" ).val( ui.value + "%" );
	    shrink(ui.value+'%');
	}
    });
    $( "#amount" ).val( $( "#slider" ).slider( "value" ) +"%" );
    shrink( $( "#slider" ).slider( "value" ) +"%" );
});

function shrink(v) {
    chrome.tabs.getSelected(null, function(tab) {
	var url = tab.url;
	if (url.indexOf('helloworldopen') != -1) {
	    console.log("hwo");
	    chrome.tabs.executeScript({
		code: "document.getElementById('content').style.backgroundColor='#667766';document.body.style.color = '#000000';"
	    });

	}
	else {
	    console.log("change width");
	    chrome.tabs.executeScript({
		code: "document.body.style.marginLeft="+"'"+v+"';"+"document.body.style.marginRight="+"'"+v+"';"
	    });
	}
    });
}
